import { IPSDataEntity } from '../ipsdata-entity';
import { IPSDELogicAction } from './ipsdelogic-action';
import { PSDEActionImplBase } from './psdeaction-impl-base';
import { IPSDELogic } from '../logic/ipsdelogic';

export class PSDELogicActionImpl extends PSDEActionImplBase implements IPSDELogicAction {
  get actionHolder(): 1 | 2 | 3 {
    return this.M.actionHolder != null ? this.M.actionHolder : 3;
  }

  protected psdelogic: IPSDELogic | null = null;

  getPSDELogic(): IPSDELogic | null {
    if (this.psdelogic != null) return this.psdelogic;
    const value = this.M.getPSDELogic;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.psdelogic = ipsdataentity.findPSDELogic(value);
    }
    return this.psdelogic;
  }

  get psDELogic(): IPSDELogic | null {
    return this.getPSDELogic();
  }

  getPSDELogicMust(): IPSDELogic {
    const value = this.getPSDELogic();
    if (value == null) {
      throw new Error('未指定实体处理逻辑');
    }
    return value;
  }

  get cls(): string {
    return 'PSDELogicActionImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.action.IPSDELogicAction') return true;
    return super.instanceof(cls);
  }
}
